from django.contrib.admin import AdminSite

class CustomAdminSite(AdminSite):
    site_header = 'CookProj 管理系统'
    site_title = '管理后台'

admin_site = CustomAdminSite(name='admin')

# 禁用删除操作
def has_delete_permission(self, request, obj=None):
    return False

# 限制查看权限
def get_queryset(self, request):
    qs = super().get_queryset(request)
    if not request.user.is_superuser:
        return qs.filter(is_public=True)
    return qs